package com.major;

import com.major.MyTask;

import java.io.*;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket();
        server.bind(new InetSocketAddress(1515));
        System.out.println("server start,listening on port 1515");

        /*while (true) {
            Socket accept = server.accept();
            MyTask myTask = new MyTask(accept);

            new Thread(myTask).start();
        }*/

        while (true) {
            Socket accept = server.accept();

            //System.out.print("A Person"+accept.getRemoteSocketAddress().toString()+"is coming for");
            ExecutorService executorService = Executors.newFixedThreadPool(20);
            executorService.submit(new MyTask(accept));
        }
    }


}
